package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.DisFlavor;
import com.itheima.reggie.entity.DishDto;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DisFlavorMapper {

    //添加口味
    @Insert("INSERT INTO dish_flavor VALUES ( null , #{dishId} , #{name} , #{value} , #{createTime} , #{updateTime} , #{createUser} , #{updateUser} , 0 );")
    void save(DisFlavor flavor);

    //根据菜品id查看口味
    @Select(" SELECT * FROM dish_flavor where dish_id = #{id} ;")
    List<DisFlavor> findByDishId(Long id);

    //根据菜品id删除
    @Delete("DELETE FROM dish_flavor WHERE dish_id = #{id};")
    void deleteByDishId(DishDto dishDto);

}
